//
//  ABSTabBarController.m
//  ABSallRec
//
//  Created by 我演示 on 2019/10/23.
//  Copyright © 2019 Jerry-Fu. All rights reserved.
//

#import "ABSTabBarController.h"
#import "ABSNavigationController.h"
#import "ABSHomeViewController.h"
#import "ABSDiscoverViewController.h"
#import "ABSMessageViewController.h"
#import "ABSMineViewController.h"
#import "ABSShoopingCartController.h"



@interface ABSTabBarController ()

@end

@implementation ABSTabBarController

/// 修改对应的外观属性

+(void)initialize {
    UITabBarItem *appearance = [UITabBarItem appearance];
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    [appearance setTitleTextAttributes:attrs forState:UIControlStateSelected];
    
    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar-light"]];
    
}

-(void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    /// 不需要替换tabbar
    [self setUpChildViewController];
    
    
    
}

/**初始化控制器信息*/

-(void)setUpChildViewController {
    
    
    ABSMineViewController *mine = [[ABSMineViewController alloc] init];
    [self setupChildViewController:mine title:@"我" image:@"tabBar_me_icon" selectedImage:@"tabBar_me_click_icon"];
    
    
 
    /**首页*/
    ABSGoodsDetailViewController *home = [[ABSGoodsDetailViewController alloc] init];
    [self setupChildViewController:home title:NSLocalizedStringFromTable(@"商品详情", @"ABSLocalizable", nil) image:@"tabBar_essence_icon" selectedImage:@"tabBar_me_click_icon"];
    
    /**首页*/
//    ABSHomeViewController *home = [[ABSHomeViewController alloc] init];
//    [self setupChildViewController:home title:NSLocalizedStringFromTable(@"haha", @"ABSLocalizable", nil) image:@"tabBar_essence_icon" selectedImage:@"tabBar_me_click_icon"];
    ABSMessageViewController *message = [[ABSMessageViewController alloc] init];
     [self setupChildViewController:message title:@"消息" image:@"tabBar_essence_icon"  selectedImage:@"tabBar_me_click_icon"];
//    [NSLocalizedStringFromTable(<#key#>, <#tbl#>, <#comment#>)]
    ///  [NSLocalizedStringFromTable(<#key#>, <#tbl#>, <#comment#>)]
    ABSDiscoverViewController *discover = [[ABSDiscoverViewController alloc] init];
    [self setupChildViewController:discover title:ABSLanguageKey(@"haha") image:@"tabBar_essence_icon" selectedImage:@"tabBar_me_click_icon"];
    

    
    ABSShoopingCartController *cart = [[ABSShoopingCartController alloc] init];
    [self setupChildViewController:cart title:@"购物车" image:@"tabBar_essence_icon" selectedImage:@"tabBar_me_click_icon"];
    
   

    
}

/**组合对应的信息*/
-(void)setupChildViewController:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
    
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    [self addChildViewController:[[ABSNavigationController alloc] initWithRootViewController:vc]];
    
}


@end
